﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using IPC.Communication;
using IPC.Communication.BasicFramework;
using IPC.Communication.Core;
using IPC.Communication.Core.Net;
using IPC.Communication.Reflection;

namespace IPC.Communication.Enthernet.Redis
{
    public class RedisClient : NetworkDoubleBase
    {
        public delegate void RedisMessageReceiveDelegate(string topic, string message);

        private string password = string.Empty;

        private int dbBlock = 0;

        private Lazy<RedisSubscribe> redisSubscribe;

        public event RedisMessageReceiveDelegate OnRedisMessageReceived;

        public RedisClient(string ipAddress, int port, string password)
        {
            base.ByteTransform = new RegularByteTransform();
            IpAddress = ipAddress;
            Port = port;
            base.ReceiveTimeOut = 30000;
            this.password = password;
            redisSubscribe = new Lazy<RedisSubscribe>(() => RedisSubscribeInitialize());
        }

        public RedisClient(string password)
        {
            base.ByteTransform = new RegularByteTransform();
            base.ReceiveTimeOut = 30000;
            this.password = password;
            redisSubscribe = new Lazy<RedisSubscribe>(() => RedisSubscribeInitialize());
        }

        protected override OperateResult InitializationOnConnect(Socket socket)
        {
            if (!string.IsNullOrEmpty(password))
            {
                byte[] send = RedisHelper.PackStringCommand(new string[2]
			{
				"AUTH",
				password
			});
                OperateResult<byte[]> operateResult = ReadFromCoreServer(socket, send);
                if (!operateResult.IsSuccess)
                {
                    return OperateResult.CreateFailedResult<string>(operateResult);
                }
                string @string = Encoding.UTF8.GetString(operateResult.Content);
                if (!@string.StartsWith("+"))
                {
                    return new OperateResult<string>(@string);
                }
            }
            if (dbBlock > 0)
            {
                byte[] send2 = RedisHelper.PackStringCommand(new string[2]
			{
				"SELECT",
				dbBlock.ToString()
			});
                OperateResult<byte[]> operateResult2 = ReadFromCoreServer(socket, send2);
                if (!operateResult2.IsSuccess)
                {
                    return OperateResult.CreateFailedResult<string>(operateResult2);
                }
                string string2 = Encoding.UTF8.GetString(operateResult2.Content);
                if (!string2.StartsWith("+"))
                {
                    return new OperateResult<string>(string2);
                }
            }
            return base.InitializationOnConnect(socket);
        }

        public override OperateResult<byte[]> ReadFromCoreServer(Socket socket, byte[] send, bool hasResponseData = true, bool usePackHeader = true)
        {
            OperateResult operateResult = Send(socket, send);
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<byte[]>(operateResult);
            }
            if (base.ReceiveTimeOut < 0)
            {
                return OperateResult.CreateSuccessResult(new byte[0]);
            }
            return ReceiveRedisCommand(socket);
        }

        //[AsyncStateMachine(typeof(<InitializationOnConnectAsync>d__4))]
        //[DebuggerStepThrough]
        //protected override Task<OperateResult> InitializationOnConnectAsync(Socket socket)
        //{
        //    <InitializationOnConnectAsync>d__4 stateMachine = new <InitializationOnConnectAsync>d__4();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.socket = socket;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadFromCoreServerAsync>d__5))]
        //[DebuggerStepThrough]
        //public override Task<OperateResult<byte[]>> ReadFromCoreServerAsync(Socket socket, byte[] send, bool hasResponseData = true, bool usePackHeader = true)
        //{
        //    <ReadFromCoreServerAsync>d__5 stateMachine = new <ReadFromCoreServerAsync>d__5();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<byte[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.socket = socket;
        //    stateMachine.send = send;
        //    stateMachine.hasResponseData = hasResponseData;
        //    stateMachine.usePackHeader = usePackHeader;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<string> ReadCustomer(string command)
        {
            byte[] send = RedisHelper.PackStringCommand(command.Split(' '));
            OperateResult<byte[]> operateResult = ReadFromCoreServer(send);
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<string>(operateResult);
            }
            return OperateResult.CreateSuccessResult(Encoding.UTF8.GetString(operateResult.Content));
        }

        //[AsyncStateMachine(typeof(<ReadCustomerAsync>d__7))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadCustomerAsync(string command)
        //{
        //    <ReadCustomerAsync>d__7 stateMachine = new <ReadCustomerAsync>d__7();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.command = command;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> OperateNumberFromServer(string[] commands)
        {
            byte[] send = RedisHelper.PackStringCommand(commands);
            OperateResult<byte[]> operateResult = ReadFromCoreServer(send);
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<int>(operateResult);
            }
            string @string = Encoding.UTF8.GetString(operateResult.Content);
            if (!@string.StartsWith(":"))
            {
                return new OperateResult<int>(@string);
            }
            return RedisHelper.GetNumberFromCommandLine(operateResult.Content);
        }

        public OperateResult<long> OperateLongNumberFromServer(string[] commands)
        {
            byte[] send = RedisHelper.PackStringCommand(commands);
            OperateResult<byte[]> operateResult = ReadFromCoreServer(send);
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<long>(operateResult);
            }
            string @string = Encoding.UTF8.GetString(operateResult.Content);
            if (!@string.StartsWith(":"))
            {
                return new OperateResult<long>(@string);
            }
            return RedisHelper.GetLongNumberFromCommandLine(operateResult.Content);
        }

        public OperateResult<string> OperateStringFromServer(string[] commands)
        {
            byte[] send = RedisHelper.PackStringCommand(commands);
            OperateResult<byte[]> operateResult = ReadFromCoreServer(send);
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<string>(operateResult);
            }
            return RedisHelper.GetStringFromCommandLine(operateResult.Content);
        }

        public OperateResult<string[]> OperateStringsFromServer(string[] commands)
        {
            byte[] send = RedisHelper.PackStringCommand(commands);
            OperateResult<byte[]> operateResult = ReadFromCoreServer(send);
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<string[]>(operateResult);
            }
            return RedisHelper.GetStringsFromCommandLine(operateResult.Content);
        }

        public OperateResult<string> OperateStatusFromServer(string[] commands)
        {
            byte[] send = RedisHelper.PackStringCommand(commands);
            OperateResult<byte[]> operateResult = ReadFromCoreServer(send);
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<string>(operateResult);
            }
            string @string = Encoding.UTF8.GetString(operateResult.Content);
            if (!@string.StartsWith("+"))
            {
                return new OperateResult<string>(@string);
            }
            return OperateResult.CreateSuccessResult(@string.Substring(1).TrimEnd('\r', '\n'));
        }

        //[AsyncStateMachine(typeof(<OperateNumberFromServerAsync>d__13))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> OperateNumberFromServerAsync(string[] commands)
        //{
        //    <OperateNumberFromServerAsync>d__13 stateMachine = new <OperateNumberFromServerAsync>d__13();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.commands = commands;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<OperateLongNumberFromServerAsync>d__14))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> OperateLongNumberFromServerAsync(string[] commands)
        //{
        //    <OperateLongNumberFromServerAsync>d__14 stateMachine = new <OperateLongNumberFromServerAsync>d__14();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.commands = commands;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<OperateStringFromServerAsync>d__15))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> OperateStringFromServerAsync(string[] commands)
        //{
        //    <OperateStringFromServerAsync>d__15 stateMachine = new <OperateStringFromServerAsync>d__15();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.commands = commands;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<OperateStringsFromServerAsync>d__16))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> OperateStringsFromServerAsync(string[] commands)
        //{
        //    <OperateStringsFromServerAsync>d__16 stateMachine = new <OperateStringsFromServerAsync>d__16();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.commands = commands;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<OperateStatusFromServerAsync>d__17))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> OperateStatusFromServerAsync(string[] commands)
        //{
        //    <OperateStatusFromServerAsync>d__17 stateMachine = new <OperateStatusFromServerAsync>d__17();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.commands = commands;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> DeleteKey(string[] keys)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("DEL", keys));
        }

        public OperateResult<int> DeleteKey(string key)
        {
            return DeleteKey(new string[1]
		{
			key
		});
        }

        public OperateResult<int> ExistsKey(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"EXISTS",
			key
		});
        }

        public OperateResult<int> ExpireKey(string key, int seconds)
        {
            return OperateNumberFromServer(new string[3]
		{
			"EXPIRE",
			key,
			seconds.ToString()
		});
        }

        public OperateResult<string[]> ReadAllKeys(string pattern)
        {
            return OperateStringsFromServer(new string[2]
		{
			"KEYS",
			pattern
		});
        }

        public OperateResult MoveKey(string key, int db)
        {
            return OperateStatusFromServer(new string[3]
		{
			"MOVE",
			key,
			db.ToString()
		});
        }

        public OperateResult<int> PersistKey(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"PERSIST",
			key
		});
        }

        public OperateResult<string> ReadRandomKey()
        {
            return OperateStringFromServer(new string[1]
		{
			"RANDOMKEY"
		});
        }

        public OperateResult RenameKey(string key1, string key2)
        {
            return OperateStatusFromServer(new string[3]
		{
			"RENAME",
			key1,
			key2
		});
        }

        public OperateResult<string> ReadKeyType(string key)
        {
            return OperateStatusFromServer(new string[2]
		{
			"TYPE",
			key
		});
        }

        public OperateResult<int> ReadKeyTTL(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"TTL",
			key
		});
        }

        //[AsyncStateMachine(typeof(<DeleteKeyAsync>d__29))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> DeleteKeyAsync(string[] keys)
        //{
        //    <DeleteKeyAsync>d__29 stateMachine = new <DeleteKeyAsync>d__29();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.keys = keys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<DeleteKeyAsync>d__30))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> DeleteKeyAsync(string key)
        //{
        //    <DeleteKeyAsync>d__30 stateMachine = new <DeleteKeyAsync>d__30();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ExistsKeyAsync>d__31))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ExistsKeyAsync(string key)
        //{
        //    <ExistsKeyAsync>d__31 stateMachine = new <ExistsKeyAsync>d__31();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ExpireKeyAsync>d__32))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ExpireKeyAsync(string key, int seconds)
        //{
        //    <ExpireKeyAsync>d__32 stateMachine = new <ExpireKeyAsync>d__32();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.seconds = seconds;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadAllKeysAsync>d__33))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ReadAllKeysAsync(string pattern)
        //{
        //    <ReadAllKeysAsync>d__33 stateMachine = new <ReadAllKeysAsync>d__33();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.pattern = pattern;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<MoveKeyAsync>d__34))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> MoveKeyAsync(string key, int db)
        //{
        //    <MoveKeyAsync>d__34 stateMachine = new <MoveKeyAsync>d__34();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.db = db;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<PersistKeyAsync>d__35))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> PersistKeyAsync(string key)
        //{
        //    <PersistKeyAsync>d__35 stateMachine = new <PersistKeyAsync>d__35();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadRandomKeyAsync>d__36))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadRandomKeyAsync()
        //{
        //    <ReadRandomKeyAsync>d__36 stateMachine = new <ReadRandomKeyAsync>d__36();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<RenameKeyAsync>d__37))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> RenameKeyAsync(string key1, string key2)
        //{
        //    <RenameKeyAsync>d__37 stateMachine = new <RenameKeyAsync>d__37();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key1 = key1;
        //    stateMachine.key2 = key2;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadKeyTypeAsync>d__38))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadKeyTypeAsync(string key)
        //{
        //    <ReadKeyTypeAsync>d__38 stateMachine = new <ReadKeyTypeAsync>d__38();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadKeyTTLAsync>d__39))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ReadKeyTTLAsync(string key)
        //{
        //    <ReadKeyTTLAsync>d__39 stateMachine = new <ReadKeyTTLAsync>d__39();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> AppendKey(string key, string value)
        {
            return OperateNumberFromServer(new string[3]
		{
			"APPEND",
			key,
			value
		});
        }

        public OperateResult<long> DecrementKey(string key)
        {
            return OperateLongNumberFromServer(new string[2]
		{
			"DECR",
			key
		});
        }

        public OperateResult<long> DecrementKey(string key, long value)
        {
            return OperateLongNumberFromServer(new string[3]
		{
			"DECRBY",
			key,
			value.ToString()
		});
        }

        public OperateResult<string> ReadKey(string key)
        {
            return OperateStringFromServer(new string[2]
		{
			"GET",
			key
		});
        }

        public OperateResult<string> ReadKeyRange(string key, int start, int end)
        {
            return OperateStringFromServer(new string[4]
		{
			"GETRANGE",
			key,
			start.ToString(),
			end.ToString()
		});
        }

        public OperateResult<string> ReadAndWriteKey(string key, string value)
        {
            return OperateStringFromServer(new string[3]
		{
			"GETSET",
			key,
			value
		});
        }

        public OperateResult<long> IncrementKey(string key)
        {
            return OperateLongNumberFromServer(new string[2]
		{
			"INCR",
			key
		});
        }

        public OperateResult<long> IncrementKey(string key, long value)
        {
            return OperateLongNumberFromServer(new string[3]
		{
			"INCRBY",
			key,
			value.ToString()
		});
        }

        public OperateResult<string> IncrementKey(string key, float value)
        {
            return OperateStringFromServer(new string[3]
		{
			"INCRBYFLOAT",
			key,
			value.ToString()
		});
        }

        public OperateResult<string[]> ReadKey(string[] keys)
        {
            return OperateStringsFromServer(SoftBasic.SpliceStringArray("MGET", keys));
        }

        public OperateResult WriteKey(string[] keys, string[] values)
        {
            if (keys == null)
            {
                throw new ArgumentNullException("keys");
            }
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            if (keys.Length != values.Length)
            {
                throw new ArgumentException("Two arguement not same length");
            }
            List<string> list = new List<string>();
            list.Add("MSET");
            for (int i = 0; i < keys.Length; i++)
            {
                list.Add(keys[i]);
                list.Add(values[i]);
            }
            return OperateStatusFromServer(list.ToArray());
        }

        public OperateResult WriteKey(string key, string value)
        {
            return OperateStatusFromServer(new string[3]
		{
			"SET",
			key,
			value
		});
        }

        public OperateResult WriteAndPublishKey(string key, string value)
        {
            OperateResult operateResult = WriteKey(key, value);
            if (!operateResult.IsSuccess)
            {
                return operateResult;
            }
            return Publish(key, value);
        }

        public OperateResult WriteExpireKey(string key, string value, long seconds)
        {
            return OperateStatusFromServer(new string[4]
		{
			"SETEX",
			key,
			seconds.ToString(),
			value
		});
        }

        public OperateResult<int> WriteKeyIfNotExists(string key, string value)
        {
            return OperateNumberFromServer(new string[3]
		{
			"SETNX",
			key,
			value
		});
        }

        public OperateResult<int> WriteKeyRange(string key, string value, int offset)
        {
            return OperateNumberFromServer(new string[4]
		{
			"SETRANGE",
			key,
			offset.ToString(),
			value
		});
        }

        public OperateResult<int> ReadKeyLength(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"STRLEN",
			key
		});
        }

        //[AsyncStateMachine(typeof(<AppendKeyAsync>d__57))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> AppendKeyAsync(string key, string value)
        //{
        //    <AppendKeyAsync>d__57 stateMachine = new <AppendKeyAsync>d__57();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<DecrementKeyAsync>d__58))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> DecrementKeyAsync(string key)
        //{
        //    <DecrementKeyAsync>d__58 stateMachine = new <DecrementKeyAsync>d__58();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<DecrementKeyAsync>d__59))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> DecrementKeyAsync(string key, long value)
        //{
        //    <DecrementKeyAsync>d__59 stateMachine = new <DecrementKeyAsync>d__59();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadKeyAsync>d__60))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadKeyAsync(string key)
        //{
        //    <ReadKeyAsync>d__60 stateMachine = new <ReadKeyAsync>d__60();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadKeyRangeAsync>d__61))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadKeyRangeAsync(string key, int start, int end)
        //{
        //    <ReadKeyRangeAsync>d__61 stateMachine = new <ReadKeyRangeAsync>d__61();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.start = start;
        //    stateMachine.end = end;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadAndWriteKeyAsync>d__62))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadAndWriteKeyAsync(string key, string value)
        //{
        //    <ReadAndWriteKeyAsync>d__62 stateMachine = new <ReadAndWriteKeyAsync>d__62();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<IncrementKeyAsync>d__63))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> IncrementKeyAsync(string key)
        //{
        //    <IncrementKeyAsync>d__63 stateMachine = new <IncrementKeyAsync>d__63();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<IncrementKeyAsync>d__64))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> IncrementKeyAsync(string key, long value)
        //{
        //    <IncrementKeyAsync>d__64 stateMachine = new <IncrementKeyAsync>d__64();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<IncrementKeyAsync>d__65))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> IncrementKeyAsync(string key, float value)
        //{
        //    <IncrementKeyAsync>d__65 stateMachine = new <IncrementKeyAsync>d__65();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadKeyAsync>d__66))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ReadKeyAsync(string[] keys)
        //{
        //    <ReadKeyAsync>d__66 stateMachine = new <ReadKeyAsync>d__66();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.keys = keys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteKeyAsync>d__67))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteKeyAsync(string[] keys, string[] values)
        //{
        //    <WriteKeyAsync>d__67 stateMachine = new <WriteKeyAsync>d__67();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.keys = keys;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteKeyAsync>d__68))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteKeyAsync(string key, string value)
        //{
        //    <WriteKeyAsync>d__68 stateMachine = new <WriteKeyAsync>d__68();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAndPublishKeyAsync>d__69))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAndPublishKeyAsync(string key, string value)
        //{
        //    <WriteAndPublishKeyAsync>d__69 stateMachine = new <WriteAndPublishKeyAsync>d__69();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteExpireKeyAsync>d__70))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteExpireKeyAsync(string key, string value, long seconds)
        //{
        //    <WriteExpireKeyAsync>d__70 stateMachine = new <WriteExpireKeyAsync>d__70();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.seconds = seconds;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteKeyIfNotExistsAsync>d__71))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> WriteKeyIfNotExistsAsync(string key, string value)
        //{
        //    <WriteKeyIfNotExistsAsync>d__71 stateMachine = new <WriteKeyIfNotExistsAsync>d__71();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteKeyRangeAsync>d__72))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> WriteKeyRangeAsync(string key, string value, int offset)
        //{
        //    <WriteKeyRangeAsync>d__72 stateMachine = new <WriteKeyRangeAsync>d__72();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.offset = offset;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadKeyLengthAsync>d__73))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ReadKeyLengthAsync(string key)
        //{
        //    <ReadKeyLengthAsync>d__73 stateMachine = new <ReadKeyLengthAsync>d__73();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> ListInsertBefore(string key, string value, string pivot)
        {
            return OperateNumberFromServer(new string[5]
		{
			"LINSERT",
			key,
			"BEFORE",
			pivot,
			value
		});
        }

        public OperateResult<int> ListInsertAfter(string key, string value, string pivot)
        {
            return OperateNumberFromServer(new string[5]
		{
			"LINSERT",
			key,
			"AFTER",
			pivot,
			value
		});
        }

        public OperateResult<int> GetListLength(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"LLEN",
			key
		});
        }

        public OperateResult<string> ReadListByIndex(string key, long index)
        {
            return OperateStringFromServer(new string[3]
		{
			"LINDEX",
			key,
			index.ToString()
		});
        }

        public OperateResult<string> ListLeftPop(string key)
        {
            return OperateStringFromServer(new string[2]
		{
			"LPOP",
			key
		});
        }

        public OperateResult<int> ListLeftPush(string key, string value)
        {
            return ListLeftPush(key, new string[1]
		{
			value
		});
        }

        public OperateResult<int> ListLeftPush(string key, string[] values)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("LPUSH", key, values));
        }

        public OperateResult<int> ListLeftPushX(string key, string value)
        {
            return OperateNumberFromServer(new string[3]
		{
			"LPUSHX",
			key,
			value
		});
        }

        public OperateResult<string[]> ListRange(string key, long start, long stop)
        {
            return OperateStringsFromServer(new string[4]
		{
			"LRANGE",
			key,
			start.ToString(),
			stop.ToString()
		});
        }

        public OperateResult<int> ListRemoveElementMatch(string key, long count, string value)
        {
            return OperateNumberFromServer(new string[4]
		{
			"LREM",
			key,
			count.ToString(),
			value
		});
        }

        public OperateResult ListSet(string key, long index, string value)
        {
            return OperateStatusFromServer(new string[4]
		{
			"LSET",
			key.ToString(),
			index.ToString(),
			value
		});
        }

        public OperateResult ListTrim(string key, long start, long end)
        {
            return OperateStatusFromServer(new string[4]
		{
			"LTRIM",
			key,
			start.ToString(),
			end.ToString()
		});
        }

        public OperateResult<string> ListRightPop(string key)
        {
            return OperateStringFromServer(new string[2]
		{
			"RPOP",
			key
		});
        }

        public OperateResult<string> ListRightPopLeftPush(string key1, string key2)
        {
            return OperateStringFromServer(new string[3]
		{
			"RPOPLPUSH",
			key1,
			key2
		});
        }

        public OperateResult<int> ListRightPush(string key, string value)
        {
            return ListRightPush(key, new string[1]
		{
			value
		});
        }

        public OperateResult<int> ListRightPush(string key, string[] values)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("RPUSH", key, values));
        }

        public OperateResult<int> ListRightPushX(string key, string value)
        {
            return OperateNumberFromServer(new string[3]
		{
			"RPUSHX",
			key,
			value
		});
        }

        //[AsyncStateMachine(typeof(<ListInsertBeforeAsync>d__91))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListInsertBeforeAsync(string key, string value, string pivot)
        //{
        //    <ListInsertBeforeAsync>d__91 stateMachine = new <ListInsertBeforeAsync>d__91();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.pivot = pivot;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListInsertAfterAsync>d__92))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListInsertAfterAsync(string key, string value, string pivot)
        //{
        //    <ListInsertAfterAsync>d__92 stateMachine = new <ListInsertAfterAsync>d__92();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.pivot = pivot;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<GetListLengthAsync>d__93))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> GetListLengthAsync(string key)
        //{
        //    <GetListLengthAsync>d__93 stateMachine = new <GetListLengthAsync>d__93();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadListByIndexAsync>d__94))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadListByIndexAsync(string key, long index)
        //{
        //    <ReadListByIndexAsync>d__94 stateMachine = new <ReadListByIndexAsync>d__94();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.index = index;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListLeftPopAsync>d__95))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ListLeftPopAsync(string key)
        //{
        //    <ListLeftPopAsync>d__95 stateMachine = new <ListLeftPopAsync>d__95();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListLeftPushAsync>d__96))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListLeftPushAsync(string key, string value)
        //{
        //    <ListLeftPushAsync>d__96 stateMachine = new <ListLeftPushAsync>d__96();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListLeftPushAsync>d__97))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListLeftPushAsync(string key, string[] values)
        //{
        //    <ListLeftPushAsync>d__97 stateMachine = new <ListLeftPushAsync>d__97();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListLeftPushXAsync>d__98))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListLeftPushXAsync(string key, string value)
        //{
        //    <ListLeftPushXAsync>d__98 stateMachine = new <ListLeftPushXAsync>d__98();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListRangeAsync>d__99))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ListRangeAsync(string key, long start, long stop)
        //{
        //    <ListRangeAsync>d__99 stateMachine = new <ListRangeAsync>d__99();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.start = start;
        //    stateMachine.stop = stop;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListRemoveElementMatchAsync>d__100))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListRemoveElementMatchAsync(string key, long count, string value)
        //{
        //    <ListRemoveElementMatchAsync>d__100 stateMachine = new <ListRemoveElementMatchAsync>d__100();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.count = count;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListSetAsync>d__101))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> ListSetAsync(string key, long index, string value)
        //{
        //    <ListSetAsync>d__101 stateMachine = new <ListSetAsync>d__101();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.index = index;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListTrimAsync>d__102))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> ListTrimAsync(string key, long start, long end)
        //{
        //    <ListTrimAsync>d__102 stateMachine = new <ListTrimAsync>d__102();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.start = start;
        //    stateMachine.end = end;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListRightPopAsync>d__103))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ListRightPopAsync(string key)
        //{
        //    <ListRightPopAsync>d__103 stateMachine = new <ListRightPopAsync>d__103();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListRightPopLeftPushAsync>d__104))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ListRightPopLeftPushAsync(string key1, string key2)
        //{
        //    <ListRightPopLeftPushAsync>d__104 stateMachine = new <ListRightPopLeftPushAsync>d__104();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key1 = key1;
        //    stateMachine.key2 = key2;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListRightPushAsync>d__105))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListRightPushAsync(string key, string value)
        //{
        //    <ListRightPushAsync>d__105 stateMachine = new <ListRightPushAsync>d__105();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListRightPushAsync>d__106))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListRightPushAsync(string key, string[] values)
        //{
        //    <ListRightPushAsync>d__106 stateMachine = new <ListRightPushAsync>d__106();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ListRightPushXAsync>d__107))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ListRightPushXAsync(string key, string value)
        //{
        //    <ListRightPushXAsync>d__107 stateMachine = new <ListRightPushXAsync>d__107();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> DeleteHashKey(string key, string field)
        {
            return DeleteHashKey(key, new string[1]
		{
			field
		});
        }

        public OperateResult<int> DeleteHashKey(string key, string[] fields)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("HDEL", key, fields));
        }

        public OperateResult<int> ExistsHashKey(string key, string field)
        {
            return OperateNumberFromServer(new string[3]
		{
			"HEXISTS",
			key,
			field
		});
        }

        public OperateResult<string> ReadHashKey(string key, string field)
        {
            return OperateStringFromServer(new string[3]
		{
			"HGET",
			key,
			field
		});
        }

        public OperateResult<string[]> ReadHashKeyAll(string key)
        {
            return OperateStringsFromServer(new string[2]
		{
			"HGETALL",
			key
		});
        }

        public OperateResult<long> IncrementHashKey(string key, string field, long value)
        {
            return OperateLongNumberFromServer(new string[4]
		{
			"HINCRBY",
			key,
			field,
			value.ToString()
		});
        }

        public OperateResult<string> IncrementHashKey(string key, string field, float value)
        {
            return OperateStringFromServer(new string[4]
		{
			"HINCRBYFLOAT",
			key,
			field,
			value.ToString()
		});
        }

        public OperateResult<string[]> ReadHashKeys(string key)
        {
            return OperateStringsFromServer(new string[2]
		{
			"HKEYS",
			key
		});
        }

        public OperateResult<int> ReadHashKeyLength(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"HLEN",
			key
		});
        }

        public OperateResult<string[]> ReadHashKey(string key, string[] fields)
        {
            return OperateStringsFromServer(SoftBasic.SpliceStringArray("HMGET", key, fields));
        }

        public OperateResult<int> WriteHashKey(string key, string field, string value)
        {
            return OperateNumberFromServer(new string[4]
		{
			"HSET",
			key,
			field,
			value
		});
        }

        public OperateResult WriteHashKey(string key, string[] fields, string[] values)
        {
            if (fields == null)
            {
                throw new ArgumentNullException("fields");
            }
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            if (fields.Length != values.Length)
            {
                throw new ArgumentException("Two arguement not same length");
            }
            List<string> list = new List<string>();
            list.Add("HMSET");
            list.Add(key);
            for (int i = 0; i < fields.Length; i++)
            {
                list.Add(fields[i]);
                list.Add(values[i]);
            }
            return OperateStatusFromServer(list.ToArray());
        }

        public OperateResult<int> WriteHashKeyNx(string key, string field, string value)
        {
            return OperateNumberFromServer(new string[4]
		{
			"HSETNX",
			key,
			field,
			value
		});
        }

        public OperateResult<string[]> ReadHashValues(string key)
        {
            return OperateStringsFromServer(new string[2]
		{
			"HVALS",
			key
		});
        }

        //[AsyncStateMachine(typeof(<DeleteHashKeyAsync>d__122))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> DeleteHashKeyAsync(string key, string field)
        //{
        //    <DeleteHashKeyAsync>d__122 stateMachine = new <DeleteHashKeyAsync>d__122();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.field = field;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<DeleteHashKeyAsync>d__123))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> DeleteHashKeyAsync(string key, string[] fields)
        //{
        //    <DeleteHashKeyAsync>d__123 stateMachine = new <DeleteHashKeyAsync>d__123();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.fields = fields;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ExistsHashKeyAsync>d__124))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ExistsHashKeyAsync(string key, string field)
        //{
        //    <ExistsHashKeyAsync>d__124 stateMachine = new <ExistsHashKeyAsync>d__124();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.field = field;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadHashKeyAsync>d__125))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ReadHashKeyAsync(string key, string field)
        //{
        //    <ReadHashKeyAsync>d__125 stateMachine = new <ReadHashKeyAsync>d__125();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.field = field;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadHashKeyAllAsync>d__126))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ReadHashKeyAllAsync(string key)
        //{
        //    <ReadHashKeyAllAsync>d__126 stateMachine = new <ReadHashKeyAllAsync>d__126();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<IncrementHashKeyAsync>d__127))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> IncrementHashKeyAsync(string key, string field, long value)
        //{
        //    <IncrementHashKeyAsync>d__127 stateMachine = new <IncrementHashKeyAsync>d__127();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.field = field;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<IncrementHashKeyAsync>d__128))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> IncrementHashKeyAsync(string key, string field, float value)
        //{
        //    <IncrementHashKeyAsync>d__128 stateMachine = new <IncrementHashKeyAsync>d__128();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.field = field;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadHashKeysAsync>d__129))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ReadHashKeysAsync(string key)
        //{
        //    <ReadHashKeysAsync>d__129 stateMachine = new <ReadHashKeysAsync>d__129();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadHashKeyLengthAsync>d__130))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ReadHashKeyLengthAsync(string key)
        //{
        //    <ReadHashKeyLengthAsync>d__130 stateMachine = new <ReadHashKeyLengthAsync>d__130();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadHashKeyAsync>d__131))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ReadHashKeyAsync(string key, string[] fields)
        //{
        //    <ReadHashKeyAsync>d__131 stateMachine = new <ReadHashKeyAsync>d__131();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.fields = fields;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteHashKeyAsync>d__132))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> WriteHashKeyAsync(string key, string field, string value)
        //{
        //    <WriteHashKeyAsync>d__132 stateMachine = new <WriteHashKeyAsync>d__132();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.field = field;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteHashKeyAsync>d__133))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteHashKeyAsync(string key, string[] fields, string[] values)
        //{
        //    <WriteHashKeyAsync>d__133 stateMachine = new <WriteHashKeyAsync>d__133();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.fields = fields;
        //    stateMachine.values = values;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteHashKeyNxAsync>d__134))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> WriteHashKeyNxAsync(string key, string field, string value)
        //{
        //    <WriteHashKeyNxAsync>d__134 stateMachine = new <WriteHashKeyNxAsync>d__134();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.field = field;
        //    stateMachine.value = value;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ReadHashValuesAsync>d__135))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ReadHashValuesAsync(string key)
        //{
        //    <ReadHashValuesAsync>d__135 stateMachine = new <ReadHashValuesAsync>d__135();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> SetAdd(string key, string member)
        {
            return SetAdd(key, new string[1]
		{
			member
		});
        }

        public OperateResult<int> SetAdd(string key, string[] members)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("SADD", key, members));
        }

        public OperateResult<int> SetCard(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"SCARD",
			key
		});
        }

        public OperateResult<string[]> SetDiff(string key, string diffKey)
        {
            return SetDiff(key, new string[1]
		{
			diffKey
		});
        }

        public OperateResult<string[]> SetDiff(string key, string[] diffKeys)
        {
            return OperateStringsFromServer(SoftBasic.SpliceStringArray("SDIFF", key, diffKeys));
        }

        public OperateResult<int> SetDiffStore(string destination, string key, string diffKey)
        {
            return SetDiffStore(destination, key, new string[1]
		{
			diffKey
		});
        }

        public OperateResult<int> SetDiffStore(string destination, string key, string[] diffKeys)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("SDIFFSTORE", destination, key, diffKeys));
        }

        public OperateResult<string[]> SetInter(string key, string interKey)
        {
            return SetInter(key, new string[1]
		{
			interKey
		});
        }

        public OperateResult<string[]> SetInter(string key, string[] interKeys)
        {
            return OperateStringsFromServer(SoftBasic.SpliceStringArray("SINTER", key, interKeys));
        }

        public OperateResult<int> SetInterStore(string destination, string key, string interKey)
        {
            return SetInterStore(destination, key, new string[1]
		{
			interKey
		});
        }

        public OperateResult<int> SetInterStore(string destination, string key, string[] interKeys)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("SINTERSTORE", destination, key, interKeys));
        }

        public OperateResult<int> SetIsMember(string key, string member)
        {
            return OperateNumberFromServer(new string[3]
		{
			"SISMEMBER",
			key,
			member
		});
        }

        public OperateResult<string[]> SetMembers(string key)
        {
            return OperateStringsFromServer(new string[2]
		{
			"SMEMBERS",
			key
		});
        }

        public OperateResult<int> SetMove(string source, string destination, string member)
        {
            return OperateNumberFromServer(new string[4]
		{
			"SMOVE",
			source,
			destination,
			member
		});
        }

        public OperateResult<string> SetPop(string key)
        {
            return OperateStringFromServer(new string[2]
		{
			"SPOP",
			key
		});
        }

        public OperateResult<string> SetRandomMember(string key)
        {
            return OperateStringFromServer(new string[2]
		{
			"SRANDMEMBER",
			key
		});
        }

        public OperateResult<string[]> SetRandomMember(string key, int count)
        {
            return OperateStringsFromServer(new string[3]
		{
			"SRANDMEMBER",
			key,
			count.ToString()
		});
        }

        public OperateResult<int> SetRemove(string key, string member)
        {
            return SetRemove(key, new string[1]
		{
			member
		});
        }

        public OperateResult<int> SetRemove(string key, string[] members)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("SREM", key, members));
        }

        public OperateResult<string[]> SetUnion(string key, string unionKey)
        {
            return SetUnion(key, new string[1]
		{
			unionKey
		});
        }

        public OperateResult<string[]> SetUnion(string key, string[] unionKeys)
        {
            return OperateStringsFromServer(SoftBasic.SpliceStringArray("SUNION", key, unionKeys));
        }

        public OperateResult<int> SetUnionStore(string destination, string key, string unionKey)
        {
            return SetUnionStore(destination, key, unionKey);
        }

        public OperateResult<int> SetUnionStore(string destination, string key, string[] unionKeys)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("SUNIONSTORE", destination, key, unionKeys));
        }

        //[AsyncStateMachine(typeof(<SetAddAsync>d__159))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetAddAsync(string key, string member)
        //{
        //    <SetAddAsync>d__159 stateMachine = new <SetAddAsync>d__159();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetAddAsync>d__160))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetAddAsync(string key, string[] members)
        //{
        //    <SetAddAsync>d__160 stateMachine = new <SetAddAsync>d__160();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.members = members;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetCardAsync>d__161))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetCardAsync(string key)
        //{
        //    <SetCardAsync>d__161 stateMachine = new <SetCardAsync>d__161();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetDiffAsync>d__162))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetDiffAsync(string key, string diffKey)
        //{
        //    <SetDiffAsync>d__162 stateMachine = new <SetDiffAsync>d__162();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.diffKey = diffKey;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetDiffAsync>d__163))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetDiffAsync(string key, string[] diffKeys)
        //{
        //    <SetDiffAsync>d__163 stateMachine = new <SetDiffAsync>d__163();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.diffKeys = diffKeys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetDiffStoreAsync>d__164))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetDiffStoreAsync(string destination, string key, string diffKey)
        //{
        //    <SetDiffStoreAsync>d__164 stateMachine = new <SetDiffStoreAsync>d__164();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.destination = destination;
        //    stateMachine.key = key;
        //    stateMachine.diffKey = diffKey;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetDiffStoreAsync>d__165))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetDiffStoreAsync(string destination, string key, string[] diffKeys)
        //{
        //    <SetDiffStoreAsync>d__165 stateMachine = new <SetDiffStoreAsync>d__165();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.destination = destination;
        //    stateMachine.key = key;
        //    stateMachine.diffKeys = diffKeys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetInterAsync>d__166))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetInterAsync(string key, string interKey)
        //{
        //    <SetInterAsync>d__166 stateMachine = new <SetInterAsync>d__166();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.interKey = interKey;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetInterAsync>d__167))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetInterAsync(string key, string[] interKeys)
        //{
        //    <SetInterAsync>d__167 stateMachine = new <SetInterAsync>d__167();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.interKeys = interKeys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetInterStoreAsync>d__168))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetInterStoreAsync(string destination, string key, string interKey)
        //{
        //    <SetInterStoreAsync>d__168 stateMachine = new <SetInterStoreAsync>d__168();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.destination = destination;
        //    stateMachine.key = key;
        //    stateMachine.interKey = interKey;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetInterStoreAsync>d__169))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetInterStoreAsync(string destination, string key, string[] interKeys)
        //{
        //    <SetInterStoreAsync>d__169 stateMachine = new <SetInterStoreAsync>d__169();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.destination = destination;
        //    stateMachine.key = key;
        //    stateMachine.interKeys = interKeys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetIsMemberAsync>d__170))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetIsMemberAsync(string key, string member)
        //{
        //    <SetIsMemberAsync>d__170 stateMachine = new <SetIsMemberAsync>d__170();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetMembersAsync>d__171))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetMembersAsync(string key)
        //{
        //    <SetMembersAsync>d__171 stateMachine = new <SetMembersAsync>d__171();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetMoveAsync>d__172))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetMoveAsync(string source, string destination, string member)
        //{
        //    <SetMoveAsync>d__172 stateMachine = new <SetMoveAsync>d__172();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.source = source;
        //    stateMachine.destination = destination;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetPopAsync>d__173))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> SetPopAsync(string key)
        //{
        //    <SetPopAsync>d__173 stateMachine = new <SetPopAsync>d__173();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetRandomMemberAsync>d__174))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> SetRandomMemberAsync(string key)
        //{
        //    <SetRandomMemberAsync>d__174 stateMachine = new <SetRandomMemberAsync>d__174();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetRandomMemberAsync>d__175))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetRandomMemberAsync(string key, int count)
        //{
        //    <SetRandomMemberAsync>d__175 stateMachine = new <SetRandomMemberAsync>d__175();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.count = count;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetRemoveAsync>d__176))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetRemoveAsync(string key, string member)
        //{
        //    <SetRemoveAsync>d__176 stateMachine = new <SetRemoveAsync>d__176();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetRemoveAsync>d__177))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetRemoveAsync(string key, string[] members)
        //{
        //    <SetRemoveAsync>d__177 stateMachine = new <SetRemoveAsync>d__177();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.members = members;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetUnionAsync>d__178))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetUnionAsync(string key, string unionKey)
        //{
        //    <SetUnionAsync>d__178 stateMachine = new <SetUnionAsync>d__178();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.unionKey = unionKey;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetUnionAsync>d__179))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> SetUnionAsync(string key, string[] unionKeys)
        //{
        //    <SetUnionAsync>d__179 stateMachine = new <SetUnionAsync>d__179();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.unionKeys = unionKeys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetUnionStoreAsync>d__180))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetUnionStoreAsync(string destination, string key, string unionKey)
        //{
        //    <SetUnionStoreAsync>d__180 stateMachine = new <SetUnionStoreAsync>d__180();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.destination = destination;
        //    stateMachine.key = key;
        //    stateMachine.unionKey = unionKey;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<SetUnionStoreAsync>d__181))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> SetUnionStoreAsync(string destination, string key, string[] unionKeys)
        //{
        //    <SetUnionStoreAsync>d__181 stateMachine = new <SetUnionStoreAsync>d__181();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.destination = destination;
        //    stateMachine.key = key;
        //    stateMachine.unionKeys = unionKeys;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> ZSetAdd(string key, string member, double score)
        {
            return ZSetAdd(key, new string[1]
		{
			member
		}, new double[1]
		{
			score
		});
        }

        public OperateResult<int> ZSetAdd(string key, string[] members, double[] scores)
        {
            if (members.Length != scores.Length)
            {
                throw new Exception(StringResources.Language.TwoParametersLengthIsNotSame);
            }
            List<string> list = new List<string>();
            list.Add("ZADD");
            list.Add(key);
            for (int i = 0; i < members.Length; i++)
            {
                list.Add(scores[i].ToString());
                list.Add(members[i]);
            }
            return OperateNumberFromServer(list.ToArray());
        }

        public OperateResult<int> ZSetCard(string key)
        {
            return OperateNumberFromServer(new string[2]
		{
			"ZCARD",
			key
		});
        }

        public OperateResult<int> ZSetCount(string key, double min, double max)
        {
            return OperateNumberFromServer(new string[4]
		{
			"ZCOUNT",
			key,
			min.ToString(),
			max.ToString()
		});
        }

        public OperateResult<string> ZSetIncreaseBy(string key, string member, double increment)
        {
            return OperateStringFromServer(new string[4]
		{
			"ZINCRBY",
			key,
			increment.ToString(),
			member
		});
        }

        public OperateResult<string[]> ZSetRange(string key, int start, int stop, bool withScore = false)
        {
            if (withScore)
            {
                return OperateStringsFromServer(new string[5]
			{
				"ZRANGE",
				key,
				start.ToString(),
				stop.ToString(),
				"WITHSCORES"
			});
            }
            return OperateStringsFromServer(new string[4]
		{
			"ZRANGE",
			key,
			start.ToString(),
			stop.ToString()
		});
        }

        public OperateResult<string[]> ZSetRangeByScore(string key, string min, string max, bool withScore = false)
        {
            if (withScore)
            {
                return OperateStringsFromServer(new string[5]
			{
				"ZRANGEBYSCORE",
				key,
				min,
				max,
				"WITHSCORES"
			});
            }
            return OperateStringsFromServer(new string[4]
		{
			"ZRANGEBYSCORE",
			key,
			min,
			max
		});
        }

        public OperateResult<int> ZSetRank(string key, string member)
        {
            return OperateNumberFromServer(new string[3]
		{
			"ZRANK",
			key,
			member
		});
        }

        public OperateResult<int> ZSetRemove(string key, string member)
        {
            return ZSetRemove(key, new string[1]
		{
			member
		});
        }

        public OperateResult<int> ZSetRemove(string key, string[] members)
        {
            return OperateNumberFromServer(SoftBasic.SpliceStringArray("ZREM", key, members));
        }

        public OperateResult<int> ZSetRemoveRangeByRank(string key, int start, int stop)
        {
            return OperateNumberFromServer(new string[4]
		{
			"ZREMRANGEBYRANK",
			key,
			start.ToString(),
			stop.ToString()
		});
        }

        public OperateResult<int> ZSetRemoveRangeByScore(string key, string min, string max)
        {
            return OperateNumberFromServer(new string[4]
		{
			"ZREMRANGEBYSCORE",
			key,
			min,
			max
		});
        }

        public OperateResult<string[]> ZSetReverseRange(string key, int start, int stop, bool withScore = false)
        {
            if (withScore)
            {
                return OperateStringsFromServer(new string[5]
			{
				"ZREVRANGE",
				key,
				start.ToString(),
				stop.ToString(),
				"WITHSCORES"
			});
            }
            return OperateStringsFromServer(new string[4]
		{
			"ZREVRANGE",
			key,
			start.ToString(),
			stop.ToString()
		});
        }

        public OperateResult<string[]> ZSetReverseRangeByScore(string key, string max, string min, bool withScore = false)
        {
            if (withScore)
            {
                return OperateStringsFromServer(new string[5]
			{
				"ZREVRANGEBYSCORE",
				key,
				max,
				min,
				"WITHSCORES"
			});
            }
            return OperateStringsFromServer(new string[4]
		{
			"ZREVRANGEBYSCORE",
			key,
			max,
			min
		});
        }

        public OperateResult<int> ZSetReverseRank(string key, string member)
        {
            return OperateNumberFromServer(new string[3]
		{
			"ZREVRANK",
			key,
			member
		});
        }

        public OperateResult<string> ZSetScore(string key, string member)
        {
            return OperateStringFromServer(new string[3]
		{
			"ZSCORE",
			key,
			member
		});
        }

        //[AsyncStateMachine(typeof(<ZSetAddAsync>d__198))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetAddAsync(string key, string member, double score)
        //{
        //    <ZSetAddAsync>d__198 stateMachine = new <ZSetAddAsync>d__198();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.score = score;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetAddAsync>d__199))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetAddAsync(string key, string[] members, double[] scores)
        //{
        //    <ZSetAddAsync>d__199 stateMachine = new <ZSetAddAsync>d__199();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.members = members;
        //    stateMachine.scores = scores;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetCardAsync>d__200))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetCardAsync(string key)
        //{
        //    <ZSetCardAsync>d__200 stateMachine = new <ZSetCardAsync>d__200();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetCountAsync>d__201))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetCountAsync(string key, double min, double max)
        //{
        //    <ZSetCountAsync>d__201 stateMachine = new <ZSetCountAsync>d__201();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.min = min;
        //    stateMachine.max = max;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetIncreaseByAsync>d__202))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ZSetIncreaseByAsync(string key, string member, double increment)
        //{
        //    <ZSetIncreaseByAsync>d__202 stateMachine = new <ZSetIncreaseByAsync>d__202();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.increment = increment;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetRangeAsync>d__203))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ZSetRangeAsync(string key, int start, int stop, bool withScore = false)
        //{
        //    <ZSetRangeAsync>d__203 stateMachine = new <ZSetRangeAsync>d__203();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.start = start;
        //    stateMachine.stop = stop;
        //    stateMachine.withScore = withScore;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetRangeByScoreAsync>d__204))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ZSetRangeByScoreAsync(string key, string min, string max, bool withScore = false)
        //{
        //    <ZSetRangeByScoreAsync>d__204 stateMachine = new <ZSetRangeByScoreAsync>d__204();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.min = min;
        //    stateMachine.max = max;
        //    stateMachine.withScore = withScore;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetRankAsync>d__205))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetRankAsync(string key, string member)
        //{
        //    <ZSetRankAsync>d__205 stateMachine = new <ZSetRankAsync>d__205();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetRemoveAsync>d__206))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetRemoveAsync(string key, string member)
        //{
        //    <ZSetRemoveAsync>d__206 stateMachine = new <ZSetRemoveAsync>d__206();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetRemoveAsync>d__207))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetRemoveAsync(string key, string[] members)
        //{
        //    <ZSetRemoveAsync>d__207 stateMachine = new <ZSetRemoveAsync>d__207();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.members = members;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetRemoveRangeByRankAsync>d__208))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetRemoveRangeByRankAsync(string key, int start, int stop)
        //{
        //    <ZSetRemoveRangeByRankAsync>d__208 stateMachine = new <ZSetRemoveRangeByRankAsync>d__208();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.start = start;
        //    stateMachine.stop = stop;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetRemoveRangeByScoreAsync>d__209))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetRemoveRangeByScoreAsync(string key, string min, string max)
        //{
        //    <ZSetRemoveRangeByScoreAsync>d__209 stateMachine = new <ZSetRemoveRangeByScoreAsync>d__209();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.min = min;
        //    stateMachine.max = max;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetReverseRangeAsync>d__210))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ZSetReverseRangeAsync(string key, int start, int stop, bool withScore = false)
        //{
        //    <ZSetReverseRangeAsync>d__210 stateMachine = new <ZSetReverseRangeAsync>d__210();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.start = start;
        //    stateMachine.stop = stop;
        //    stateMachine.withScore = withScore;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetReverseRangeByScoreAsync>d__211))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string[]>> ZSetReverseRangeByScoreAsync(string key, string max, string min, bool withScore = false)
        //{
        //    <ZSetReverseRangeByScoreAsync>d__211 stateMachine = new <ZSetReverseRangeByScoreAsync>d__211();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.max = max;
        //    stateMachine.min = min;
        //    stateMachine.withScore = withScore;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetReverseRankAsync>d__212))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> ZSetReverseRankAsync(string key, string member)
        //{
        //    <ZSetReverseRankAsync>d__212 stateMachine = new <ZSetReverseRankAsync>d__212();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ZSetScoreAsync>d__213))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<string>> ZSetScoreAsync(string key, string member)
        //{
        //    <ZSetScoreAsync>d__213 stateMachine = new <ZSetScoreAsync>d__213();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.key = key;
        //    stateMachine.member = member;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<T> Read<T>() where T : class, new()
        {
            return HslReflectionHelper.Read<T>(this);
        }

        public OperateResult Write<T>(T data) where T : class, new()
        {
            return HslReflectionHelper.Write(data, this);
        }

        //[AsyncStateMachine(typeof(<ReadAsync>d__216<>))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<T>> ReadAsync<T>() where T : class, new()
        //{
        //    <ReadAsync>d__216<T> stateMachine = new <ReadAsync>d__216<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<T>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<WriteAsync>d__217<>))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> WriteAsync<T>(T data) where T : class, new()
        //{
        //    <WriteAsync>d__217<T> stateMachine = new <WriteAsync>d__217<T>();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.data = data;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult Save()
        {
            return OperateStatusFromServer(new string[1]
		{
			"SAVE"
		});
        }

        public OperateResult SaveAsync()
        {
            return OperateStatusFromServer(new string[1]
		{
			"BGSAVE"
		});
        }

        public OperateResult<DateTime> ReadServerTime()
        {
            OperateResult<string[]> operateResult = OperateStringsFromServer(new string[1]
		{
			"TIME"
		});
            if (!operateResult.IsSuccess)
            {
                return OperateResult.CreateFailedResult<DateTime>(operateResult);
            }
            long num = long.Parse(operateResult.Content[0]);
            DateTime value = new DateTime(1970, 1, 1, 8, 0, 0).AddSeconds(num);
            return OperateResult.CreateSuccessResult(value);
        }

        public OperateResult Ping()
        {
            return OperateStatusFromServer(new string[1]
		{
			"PING"
		});
        }

        public OperateResult<long> DBSize()
        {
            return OperateLongNumberFromServer(new string[1]
		{
			"DBSIZE"
		});
        }

        public OperateResult FlushDB()
        {
            return OperateStatusFromServer(new string[1]
		{
			"FLUSHDB"
		});
        }

        public OperateResult ChangePassword(string password)
        {
            return OperateStatusFromServer(new string[4]
		{
			"CONFIG",
			"SET",
			"requirepass",
			password
		});
        }

        //[AsyncStateMachine(typeof(<ReadServerTimeAsync>d__225))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<DateTime>> ReadServerTimeAsync()
        //{
        //    <ReadServerTimeAsync>d__225 stateMachine = new <ReadServerTimeAsync>d__225();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<DateTime>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<PingAsync>d__226))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> PingAsync()
        //{
        //    <PingAsync>d__226 stateMachine = new <PingAsync>d__226();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<DBSizeAsync>d__227))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<long>> DBSizeAsync()
        //{
        //    <DBSizeAsync>d__227 stateMachine = new <DBSizeAsync>d__227();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<long>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<FlushDBAsync>d__228))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> FlushDBAsync()
        //{
        //    <FlushDBAsync>d__228 stateMachine = new <FlushDBAsync>d__228();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        //[AsyncStateMachine(typeof(<ChangePasswordAsync>d__229))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> ChangePasswordAsync(string password)
        //{
        //    <ChangePasswordAsync>d__229 stateMachine = new <ChangePasswordAsync>d__229();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.password = password;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult<int> Publish(string channel, string message)
        {
            return OperateNumberFromServer(new string[3]
		{
			"PUBLISH",
			channel,
			message
		});
        }

        //[AsyncStateMachine(typeof(<PublishAsync>d__231))]
        //[DebuggerStepThrough]
        //public Task<OperateResult<int>> PublishAsync(string channel, string message)
        //{
        //    <PublishAsync>d__231 stateMachine = new <PublishAsync>d__231();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult<int>>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.channel = channel;
        //    stateMachine.message = message;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        public OperateResult SelectDB(int db)
        {
            OperateResult operateResult = OperateStatusFromServer(new string[2]
		{
			"SELECT",
			db.ToString()
		});
            if (operateResult.IsSuccess)
            {
                dbBlock = db;
            }
            return operateResult;
        }

        //[AsyncStateMachine(typeof(<SelectDBAsync>d__233))]
        //[DebuggerStepThrough]
        //public Task<OperateResult> SelectDBAsync(int db)
        //{
        //    <SelectDBAsync>d__233 stateMachine = new <SelectDBAsync>d__233();
        //    stateMachine.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
        //    stateMachine.<>4__this = this;
        //    stateMachine.db = db;
        //    stateMachine.<>1__state = -1;
        //    stateMachine.<>t__builder.Start(ref stateMachine);
        //    return stateMachine.<>t__builder.Task;
        //}

        private RedisSubscribe RedisSubscribeInitialize()
        {
            RedisSubscribe redisSubscribe = new RedisSubscribe(IpAddress, Port);
            redisSubscribe.Password = password;
            redisSubscribe.OnRedisMessageReceived += delegate(string topic, string message)
            {
                if (this.OnRedisMessageReceived != null)
                {
                    this.OnRedisMessageReceived.Invoke(topic, message);
                }
            };
            return redisSubscribe;
        }

        public OperateResult SubscribeMessage(string topic)
        {
            return SubscribeMessage(new string[1]
		{
			topic
		});
        }

        public OperateResult SubscribeMessage(string[] topics)
        {
            return redisSubscribe.Value.SubscribeMessage(topics);
        }

        public OperateResult UnSubscribeMessage(string topic)
        {
            return UnSubscribeMessage(new string[1]
		{
			topic
		});
        }

        public OperateResult UnSubscribeMessage(string[] topics)
        {
            return redisSubscribe.Value.UnSubscribeMessage(topics);
        }

        public override string ToString()
        {
            return String.Format("RedisClient[{0}:{1}]", IpAddress, Port);
        }
    }
}
